package com.entrogy.dao;

import com.alibaba.fastjson.JSONObject;
import com.entrogy.bean.CourseHomeworkEntity;
import com.entrogy.bean.HomeworkEntity;
import com.entrogy.bean.StudentEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName HomeworkServiceMapper
 * @Description
 * @Author luoxingjiang
 * @Date 2019/7/22 0022 上午 11:15
 * @Version 1.0
 **/
@Repository
public interface HomeworkMapper {
    /**
     * 得到作业概览
     * @param teacherId
     * @param schoolCode
     * @param classId
     * @return
     */
    List<HomeworkEntity> listHomeworkInfo(@Param(value = "teacherId") String teacherId, @Param(value = "schoolCode") Integer schoolCode, @Param(value = "classId") Integer classId, @Param(value = "courseId") Integer courseId);

    /**
     * 添加作业
     * @param homework
     * @return
     */
    Integer addHomework(HomeworkEntity homework);

    /**
     * 添加作业的图片地址信息
     * @param homeworkId
     * @param imageUrls
     * @return
     */
    Integer addHomeworkImageUrl(@Param(value = "homeworkId") Integer homeworkId, @Param(value = "imageUrls") List<String> imageUrls);

    /**
     * 查询某一个班级的所有家长的openid
     * @param classId
     * @param schoolCode
     * @return
     */
    List<String> listClassParentOpenId(@Param(value = "classId") Integer classId, @Param(value = "schoolCode") Integer schoolCode);

    /**
     * 根据作业id获取详情
     * @param homeworkId
     * @return
     */
    HomeworkEntity getHomeworkDetail(Integer homeworkId);

    /**
     * 获取家长的孩子列表
     * @param uid
     * @return
     */
    List<JSONObject> listStudentByParentId(String uid);

    /**
     * 获取教师所教科目用于布置作业
     *
     * @param schoolCode
     * @param uid
     * @return
     */
    List<CourseHomeworkEntity> listClassAndCourse(@Param(value = "schoolCode") Integer schoolCode, @Param(value = "teacherId") String uid);

    /**
     * 查询某个学生的作业列表
     * @param studentId
     * @return
     */
    List<HomeworkEntity> listStudentHomeworkInfo(Integer studentId);

    /**
     * 查询某个老师在某个班级发送的某一个科目作业的总数
     * @param teacherId
     * @param classId
     * @param courseId
     * @return
     */
    Integer countTeacherSendHomework(@Param(value = "teacherId") String teacherId, @Param(value = "classId") Integer classId, @Param(value = "courseId") Integer courseId);

    /**
     * 查询某个学生接收到的作业的总条数
     * @param studentId
     * @return
     */
    Integer countStudentReceiveHomework(@Param("studentId") Integer studentId);

    /**
     * 新增作业发送记录
     * @param homeworkId
     * @param teacherId
     * @param sendParentOpenIdList
     * @return
     */
    int insertHomeworkSendRecord(@Param("homeworkId") Integer homeworkId, @Param("teacherId") String teacherId, @Param("sendParentOpenIdList") List<String> sendParentOpenIdList);
}
